<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head />
    <h:body>
        <ui:composition template="template.xhtml">
            
            <ui:define name="title">
                Home
            </ui:define>
            
            <ui:define name="content">
                <!--______________ MAIN CONTENT ______________-->
                <h:form>
                    <h3>Calendar</h3>
                    <p:schedule value="#{scheduleView.loggedUserEvents}" draggable="false" ignoreTimezone="false" resizable="false" >
                        <p:ajax event="eventSelect" listener="#{scheduleView.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
                    </p:schedule>
                    <p:dialog widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">
                        <h:panelGrid id="eventDetails" columns="2">
                            <h:outputLabel for="title" value="Title:" />
                            <h:outputText id="title" value="#{scheduleView.event.title}" />
                            
                            <h:outputLabel for="from" value="From:" />
                            <h:outputText id="from" value="#{scheduleView.event.startDate}">
                                <f:convertDateTime pattern="dd/MM/yyyy  HH:mm:ss" timeZone="GMT+1"/>
                            </h:outputText>
                            
                            <h:outputLabel for="to" value="To:" />
                            <h:outputText id="to" value="#{scheduleView.event.endDate}">
                                <f:convertDateTime pattern="dd/MM/yyyy  HH:mm:ss" timeZone="GMT+1"/>
                            </h:outputText>
                            
                            <h:outputLabel for="location" value="Location:"/> 
                            <h:outputLabel id="location" value="#{scheduleView.event.data.location}"/>
                            
                            <h:outputLabel for="notPredefinedTypology" value="Typology:" rendered="#{scheduleView.event.data.predefinedTypology == 'other'}"/> 
                            <h:outputLabel id="notPredefinedTypology" value="#{scheduleView.event.data.notPredefinedTypology}" rendered="#{scheduleView.event.data.predefinedTypology == 'other'}"/>
                            
                            <h:outputLabel for="predefinedTypology" value="Typology: " rendered="#{scheduleView.event.data.predefinedTypology != 'other'}"/> 
                            <h:outputLabel id="predefinedTypology" value="#{scheduleView.event.data.predefinedTypology}" rendered="#{scheduleView.event.data.predefinedTypology != 'other'}"/>               
                            
                            <h:outputLabel for="outdoor" value="Outdoor:"/> 
                            <h:outputLabel id="outdoor" value="#{scheduleView.event.data.outdoor}"/>
                            
                            <h:outputLabel for="weatherForecast" value="Weather Forecast:" rendered="#{scheduleView.event.data.weatherForecast != null}"/>
                            <p:graphicImage id="weatherForecast" value="http://openweathermap.org/img/w/#{scheduleView.event.data.weatherForecast.icon}.png" rendered="#{scheduleView.event.data.weatherForecast != null}"/>
                            
                            <h:outputLabel for="tempForecast" value="Temperature Forecast:" rendered="#{scheduleView.event.data.weatherForecast != null}"/>
                            <h:outputLabel id="tempForecast" value="#{scheduleView.event.data.weatherForecast.temperatureFormat} °C" rendered="#{scheduleView.event.data.weatherForecast != null}"/>
                            
                            <br/>
                            <h:outputLabel id="rainForecasted" value="Expected rain" rendered="#{scheduleView.event.data.weatherForecast != null 
                                                                                                   and scheduleView.event.data.weatherForecast.precipitation == true}"/>
                            
                            <h:outputLabel id="NOrainForecasted" value="NO expected rain" rendered="#{scheduleView.event.data.weatherForecast != null 
                                                                                                        and scheduleView.event.data.weatherForecast.precipitation == false}"/>
                            
                            <h:outputLabel for="windForecast" value="Wind Forecast:" rendered="#{scheduleView.event.data.weatherForecast != null}"/>
                            <h:outputLabel id="windForecast" value="#{scheduleView.event.data.weatherForecast.wind} m/s" rendered="#{scheduleView.event.data.weatherForecast != null}"/>
                            
                        </h:panelGrid>

                            <h:commandButton value="View Event" action="#{scheduleView.goToEvent(scheduleView.event.data)}"/>
                        
                    </p:dialog>    
                </h:form>
            </ui:define>
            
        </ui:composition>
    </h:body>
</html>